package org.jeecg.modules.project.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.interview.entity.Interview;
import org.jeecg.modules.project.entity.Project;
import org.jeecg.modules.project.service.ProjectService;
import org.jeecg.modules.upload.FileUploadUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import java.io.IOException;
import java.io.InputStream;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liujiamiao
 * @since 2020-11-04
 */
@Validated
@RestController
@RequestMapping("/project/project")
@Api(tags = "项目情况接口")
public class ProjectController {

    @Autowired
    private ProjectService projectService;

    @ApiOperation(value = "分页查询")
    @PostMapping("/list/{page}/{limit}/{basicId}")
    public Result list(@ApiParam("第几页") @PathVariable("page")Integer page,
                       @ApiParam("分页的数量") @PathVariable("limit") Integer limit,
                       @ApiParam("基本信息id") @PathVariable("basicId") Integer basicId){
        IPage<Project> pageList = projectService.pageSelect(page,limit,basicId);
        return Result.ok(pageList);
    }

    @ApiOperation("保存/更新项目经验")
    @PostMapping("/save")
    public Result save(@Valid @ApiParam("项目数据") @RequestBody Project project){
        projectService.saveOrUpdate(project);
        return Result.ok();
    }

    @ApiOperation("删除该项目经验")
    @DeleteMapping("/delete/{id}")
    public Result deleteById(@ApiParam("项目id") @PathVariable("id") Integer id){
        projectService.removeById(id);
        return Result.ok();
    }

    @ApiOperation("更新项目经验")
    @PutMapping("/update")
    public Result updaate(@ApiParam("项目数据") @RequestBody Project project){
        projectService.updateById(project);
        return Result.ok();
    }

    @ApiOperation("根据项目id获取项目信息")
    @GetMapping("/info/{id}")
    public Result info(@ApiParam("项目id") @PathVariable Integer id){
        Project project = projectService.getById(id);
        return Result.ok(project);
    }

}

